package de.hft.st.algodat.ctt.model;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

public class Curriculum {
	private String id;
	private Vector<String> courses = new Vector<String>();
	private List<Course> cList = new ArrayList<Course>();

	protected Curriculum(String id, Vector<String> courses, List<Course> cList) {
		this.id = id;
		this.courses = courses;
		this.cList = cList;
	}

	@Override
	public String toString() {
		StringBuffer toStr = new StringBuffer();
		toStr.append("Curric. ID|# Courses |Courses\n");
		toStr.append(String.format("%-10s|", id));
		toStr.append(String.format("%-10s|", courses.size()));
		for (Iterator<String> itr = courses.iterator(); itr.hasNext();) {
			toStr.append(itr.next() + " ");
		}
		return toStr.toString() + "\n";
	}

	public String getId() {
		return id;
	}

	protected Vector<String> getCourses() {
		return courses;
	}
	
	protected int getNumberOfCourses() {
		return this.cList.size();
	}
	
	public List<Course> getCList() {
		return this.cList;
	}

	public boolean hasCourse(Course assigned) {
		boolean hasCourse = false;
		for(Iterator<Course> itr = this.cList.iterator(); itr.hasNext();) {
			Course helper = itr.next();
			if(helper.getId().equals(assigned.getId())) {
//				System.out.println(assigned.getId());
				hasCourse = true;
				break;
			}
		}
		return hasCourse;
	}

	public boolean containsCourseByRef(String courseID) {
		boolean containsCourse = false;
		for(Iterator<Course> itr = this.cList.iterator(); itr.hasNext();) {
			if(itr.next().getId().equals(courseID)) {
				containsCourse = true;
				break;
			}
		}
		return containsCourse;
	}
}
